package com.sxhuayuan.parking.entity;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;

import javax.persistence.*;
import java.math.BigDecimal;
import java.time.LocalDate;

/**
 * 月分润结算表
 * 
 * @author 何龙
 * @create 2019-05-22 16:55
 */
@Entity
@Table(name = "hypk_monthly_profit")
public class MonthlyProfit extends BaseEntity {

	public enum State {
		/** 待确认 */
		waitConfirm,

		/** 待核算 */
		waitCalculation,

		/** 待打款 */
		waitRemittance,

		/** 已打款 */
		remittance
	}

	/** 代理 */
	private Agent agent;

	/** 统计的分润年月 */
	@JsonFormat(pattern = "yyyy-MM")
	private LocalDate statistisMonth;

	/** 总流水金额 */
	private BigDecimal totalMoney = BigDecimal.ZERO;

	/** 总订单数 */
	private Long totalCount = 0L;

	/** 微信流水 */
	private BigDecimal weixinMoney = BigDecimal.ZERO;

	/** 微信订单数 */
	private Long weixinCount = 0L;

	/** 支付宝流水 */
	private BigDecimal alipayMoney = BigDecimal.ZERO;

	/** 支付宝订单数 */
	private Long alipayCount = 0L;

	/** 总原始分润 */
	private BigDecimal totalOriginalProfit = BigDecimal.ZERO;

	/** 总分润 */
	private BigDecimal totalProfit = BigDecimal.ZERO;

	/** 微信分润 */
	private BigDecimal weixinProfit = BigDecimal.ZERO;

	/** 微信原始分润 */
	private BigDecimal weixinOriginalProfit = BigDecimal.ZERO;

	/** 支付宝分润 */
	private BigDecimal alipayProfit = BigDecimal.ZERO;

	/** 支付宝原始分润 */
	private BigDecimal alipayOriginalProfit = BigDecimal.ZERO;

	/** 状态 */
	private State state = State.waitConfirm;

	@JSONField(serialize = false)
	@JoinColumn(name = "agent_id")
	@ManyToOne(fetch = FetchType.LAZY)
	public Agent getAgent() {
		return agent;
	}

	public void setAgent(Agent agent) {
		this.agent = agent;
	}

	@Column(nullable = false, columnDefinition = "decimal(19,2) default '0'")
	public BigDecimal getTotalMoney() {
		return totalMoney;
	}

	public void setTotalMoney(BigDecimal totalMoney) {
		this.totalMoney = totalMoney == null ? BigDecimal.ZERO : totalMoney;
	}

	@Column(nullable = false, columnDefinition = "decimal(19,2) default '0'")
	public BigDecimal getWeixinMoney() {
		return weixinMoney;
	}

	public void setWeixinMoney(BigDecimal weixinMoney) {
		this.weixinMoney = weixinMoney == null ? BigDecimal.ZERO : weixinMoney;
	}

	@Column(nullable = false, columnDefinition = "decimal(19,2) default '0'")
	public BigDecimal getAlipayMoney() {
		return alipayMoney;
	}

	public void setAlipayMoney(BigDecimal alipayMoney) {
		this.alipayMoney = alipayMoney == null ? BigDecimal.ZERO : alipayMoney;
	}

	@Column(nullable = false, columnDefinition = "decimal(19,2) default '0'")
	public BigDecimal getTotalProfit() {
		return totalProfit;
	}

	public void setTotalProfit(BigDecimal totalProfit) {
		this.totalProfit = totalProfit == null ? BigDecimal.ZERO : totalProfit;
	}

	@Column(nullable = false, columnDefinition = "decimal(19,2) default '0'")
	public BigDecimal getWeixinProfit() {
		return weixinProfit;
	}

	public void setWeixinProfit(BigDecimal weixinProfit) {
		this.weixinProfit = weixinProfit == null ? BigDecimal.ZERO : weixinProfit;
	}

	@Column(nullable = false, columnDefinition = "decimal(19,2) default '0'")
	public BigDecimal getAlipayProfit() {
		return alipayProfit;
	}

	public void setAlipayProfit(BigDecimal alipayProfit) {
		this.alipayProfit = alipayProfit == null ? BigDecimal.ZERO : alipayProfit;
	}

	public Long getTotalCount() {
		return totalCount;
	}

	public void setTotalCount(Long totalCount) {
		this.totalCount = totalCount == null ? 0L : totalCount;
	}

	public Long getWeixinCount() {
		return weixinCount;
	}

	public void setWeixinCount(Long weixinCount) {
		this.weixinCount = weixinCount == null ? 0L : weixinCount;
	}

	public Long getAlipayCount() {
		return alipayCount;
	}

	public void setAlipayCount(Long alipayCount) {
		this.alipayCount = alipayCount == null ? 0L : alipayCount;
	}

	@Column(nullable = false)
	public LocalDate getStatistisMonth() {
		return statistisMonth;
	}

	public void setStatistisMonth(LocalDate statistisMonth) {
		this.statistisMonth = statistisMonth;
	}

	@Column(nullable = false, columnDefinition = "decimal(19,2) default '0'")
	public BigDecimal getTotalOriginalProfit() {
		return totalOriginalProfit;
	}

	public void setTotalOriginalProfit(BigDecimal totalOriginalProfit) {
		this.totalOriginalProfit = totalOriginalProfit == null ? BigDecimal.ZERO : totalOriginalProfit;
	}

	@Column(nullable = false, columnDefinition = "decimal(19,2) default '0'")
	public BigDecimal getWeixinOriginalProfit() {
		return weixinOriginalProfit;
	}

	public void setWeixinOriginalProfit(BigDecimal weixinOriginalProfit) {
		this.weixinOriginalProfit = weixinOriginalProfit == null ? BigDecimal.ZERO : weixinOriginalProfit;
	}

	@Column(nullable = false, columnDefinition = "decimal(19,2) default '0'")
	public BigDecimal getAlipayOriginalProfit() {
		return alipayOriginalProfit;
	}

	public void setAlipayOriginalProfit(BigDecimal alipayOriginalProfit) {
		this.alipayOriginalProfit = alipayOriginalProfit == null ? BigDecimal.ZERO : alipayOriginalProfit;
	}

	public State getState() {
		return state;
	}

	public void setState(State state) {
		this.state = state;
	}

	@Override
	public String toString() {
		return "MonthlyProfit{" + "agent=" + agent + ", statistisMonth=" + statistisMonth + ", totalMoney=" + totalMoney + ", totalCount=" + totalCount + ", weixinMoney=" + weixinMoney
				+ ", weixinCount=" + weixinCount + ", alipayMoney=" + alipayMoney + ", alipayCount=" + alipayCount + ", totalOriginalProfit=" + totalOriginalProfit + ", totalProfit="
				+ totalProfit + ", weixinProfit=" + weixinProfit + ", weixinOriginalProfit=" + weixinOriginalProfit + ", alipayProfit=" + alipayProfit + ", alipayOriginalProfit="
				+ alipayOriginalProfit + ", state=" + state + '}';
	}
}
